from fastapi import APIRouter
from starlette.requests import Request
from fastapi.templating import Jinja2Templates

task_router = APIRouter(prefix='/task')
templates = Jinja2Templates(directory="templates")


# 获取所有任务
@task_router.get("/tasks")
def get_tasks(request: Request, limit: int = 10, skip: int = 0):
    res = {
        "code": 0,
        "message": "success",
        "data": [
            {
                "id": i,
                "username": f"username{i}",
                "sex": "编写项目报告并提交",
                "city": False,
                "sign": False,
                "experience": False,
                "score": False,
                "classify": False
            }
            for i in range(1, limit + 1)
        ]
    }
    return res


# 获取所有任务
@task_router.get("/taskList")
def get_tasks(request: Request, limit: int = 10, skip: int = 0):
    res = {
        "code": 0,
        "message": "success",
        "total": 100,
        "data": [
            {
                "id": i,
                "username": f"username{i}",
                "sex": "编写项目报告并提交",
                "city": False,
                "sign": False,
                "experience": False,
                "score": False,
                "classify": False
            }
            for i in range(1, limit + 1)
        ]
    }
    return templates.TemplateResponse("page_task_list.html", {"request": request, "tasks": res})
